<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_data_tables.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:01 GMT -->

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>对账接入者管理系统</title>
    <meta name="keywords" content="对账接入者管理系统">
    <meta name="description" content="对账接入者管理系统">

    <link rel="shortcut icon" href="{{asset('dealer/img/favicon.ico')}}">
    <link href="{{asset('dealer/css/bootstrap.min.css')}}" rel="stylesheet">
    <link href="{{asset('dealer/css/font-awesome.min.css')}}" rel="stylesheet">

    <!-- Data Tables -->
    <link href="{{asset('dealer/css/plugins/dataTables/dataTables.bootstrap.css')}}" rel="stylesheet">

    <link href="{{asset('dealer/css/animate.min.css')}}" rel="stylesheet">
    <link href="{{asset('dealer/css/style.min.css')}}" rel="stylesheet">

    <link href="{{asset('layui-v2.3.0/layui/css/layui.css')}}" rel="stylesheet">


</head>

<body class="gray-bg">
<style>
    table.dataTable thead .sorting:after {
        content: "";
    }

    table.dataTable,
    .table-bordered {
        text-align: center;
    }

</style>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-5">
            {{--<strong style="display:inline-block;padding-top: 10px;font-size: 20px;">推荐总人数：--}}
            {{--<span style="font-size: 20px">50000</span>人</strong>--}}
        </div>
        <div class="col-sm-5 m-b-xs">
            <div class="input-group" id="datepicker" style="margin-left: 10%;">

                <input type="text"  placeholder="请输入年份" class="input-sm form-control" style="margin-left:0;text-align: center;" id="incomeyear" value="{{date('Y')}}">
                <span class="input-group-addon">年</span>
                <input type="text" placeholder="请输入月份" class="input-sm form-control" style="margin-left:0;text-align: center;" id="incomemonth" value="{{date('m')}}">
                <span class="input-group-addon">月</span>
                <span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary" onclick="searchIncome()"> 搜索</button>
</span>
            </div>
            {{--<div class="form-group" id="" style="margin-top: 10px;margin-bottom:0">--}}
                {{--<div class="input-daterange input-group" id="datepicker" style="margin-left: 10%;">--}}
                    {{--<span class="input-group-addon">时间段：</span>--}}
                    {{--<input type="text" class="input-sm form-control" id="incomeyear" name="start" value="{{date('Y')}}" style="margin-left: 0" />--}}
                    {{--<span class="input-group-addon">年</span>--}}
                    {{--<input type="text" class="input-sm form-control" id="incomemonth" name="end" value="{{date('m')}}" style="margin-left: 0" />--}}
                    {{--<span class="input-group-addon">月</span>--}}
                    {{--<button type="button" class="btn btn-sm btn-primary" style="position: absolute" onclick="searchIncome()"> 查询</button>--}}
                {{--</div>--}}
            {{--</div>--}}



        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">

            <div id="main" style="width: 800px;height:400px"></div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-4">
            <strong style="display:inline-block;font-size: 20px;">分类统计收入</strong>
        </div>
        <div class="col-sm-5 m-b-xs" style="width: 46%">
            <div class="input-group">
                <span class="input-group-addon">时间段：</span>
                <input type="text" placeholder="请选择日期" class="input-sm form-control" style="margin-left:0" id="datetime" value="{{date('Y-m-d')}}">
                <span class="input-group-addon">到</span>
                <input type="text" placeholder="请选择日期" class="input-sm form-control" style="margin-left:0" id="datetime1" value="{{date('Y-m-d')}}">
                <span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary" onclick="searchclassification()"> 搜索</button>
</span>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">

            <div id="annularChart" style="width: 600px;height:400px;margin-top: 20px;"></div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-5">
            {{--<strong style="display:inline-block;padding-top: 10px;font-size: 20px;">推荐总人数：--}}
                {{--<span style="font-size: 20px">50000</span>人</strong>--}}
        </div>
        <div class="col-sm-5 m-b-xs" style="width: 46%">
            <div class="input-group" id="datepicker" style="margin-left: 10%;">

                <input type="text" placeholder="请输入年份" class="input-sm form-control" style="margin-left:0;text-align: center;" id="referenceyear" value="{{date('Y')}}">
                <span class="input-group-addon">年</span>
                <input type="text" placeholder="请输入月份" class="input-sm form-control" style="margin-left:0;text-align: center;" id="referencemonth" value="{{date('m')}}">
                <span class="input-group-addon">月</span>
                <span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary" onclick="searchReference()"> 搜索</button>
</span>
            </div>
            {{--<div class="form-group" style="margin-top: 10px;margin-bottom: 0">--}}
                {{--<div class="input-daterange input-group" id="datepicker" style="margin-left: 10%;">--}}
                    {{--<span class="input-group-addon">时间段：</span>--}}
                    {{--<input type="text" class="input-sm form-control" id="referenceyear" name="start" value="{{date('Y')}}" style="margin-left: 0" />--}}
                    {{--<span class="input-group-addon">年</span>--}}
                    {{--<input type="text" class="input-sm form-control" id="referencemonth" name="end" value="{{date('m')}}" style="margin-left: 0" />--}}
                    {{--<span class="input-group-addon">月</span>--}}
                    {{--<button type="button" class="btn btn-sm btn-primary" style="position: absolute" onclick="searchReference()"> 查询</button>--}}
                {{--</div>--}}
            {{--</div>--}}
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">

            <div id="main3" style="width: 800px;height:400px"></div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-4">
            <strong style="display:inline-block;font-size: 20px;">分类统计人数</strong>
        </div>
        <div class="col-sm-5 m-b-xs" style="width: 46%;">
            <div class="input-group">
                <span class="input-group-addon">时间段：</span>
                <input type="text" placeholder="请选择日期" class="input-sm form-control" style="margin-left:0" id="datetime2" value="{{date('Y-m-d')}}">
                <span class="input-group-addon">到</span>
                <input type="text" placeholder="请选择日期" class="input-sm form-control" style="margin-left:0" id="datetime3" value="{{date('Y-m-d')}}">
                <span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary" onclick="searchclassificationPe()"> 搜索</button>
</span>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">

            <div id="annularChart4" style="width: 600px;height:400px;margin-top: 20px;"></div>
        </div>
    </div>
</div>
<script src="{{asset('dealer/js/echarts.js')}}"></script>
<script src="{{asset('dealer/js/jquery.min.js')}}"></script>
<!-- 引用下边三个日期插件script会使表格插件不生效!-->

{{--<script src="{{asset('dealer/js/demo/form-advanced-demo.min.js')}}"></script>--}}


<script src="{{asset('laydate/laydate.js')}}"></script>

<script src="{{asset('layui-v2.3.0/layui/layui.js')}}"></script>

<script>
</script>


</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_data_tables.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:02 GMT -->

</html>


<script type="text/javascript">
    $(document).ready(function () {



        //两个日期范围选择
        layui.use(['laydate', 'jquery'], function () {
            var laydate = layui.laydate,
                $ = layui.jquery;
            var startIns = laydate.render({
                elem: '#datetime',
                max: 'new Date()',
                done: function (value, date, endDate) {
                    var min = $.extend({}, date),
                        max = $.extend({}, date);
                    min.month = min.month - 1;
                    max.month = max.month - 1;
                    //两个时间相差天数
                    var begintime = new Date().getTime();
                    var endtime = new Date(Date.parse(value)).getTime();
                    var nTime = begintime - endtime;
                    var day = Math.floor(nTime / 86400000);
                    max.date = max.date + day;

                    endIns.config.min = min;
                    endIns.config.max = max;
                    endIns.config.value = value;
                    $(endIns.config.elem).val(value);
                }
            });
            var endIns = laydate.render({
                elem: '#datetime1',
                min: 'value',
                done: function (value, date, endDate) {}
            });
        });





        //两个日期范围选择
        layui.use(['laydate', 'jquery'], function () {
            var laydate = layui.laydate,
                $ = layui.jquery;
            var startIns = laydate.render({
                elem: '#datetime2',
                max: 'new Date()',
                done: function (value, date, endDate) {
                    var min = $.extend({}, date),
                        max = $.extend({}, date);
                    min.month = min.month - 1;
                    max.month = max.month - 1;
                    //两个时间相差天数
                    var begintime = new Date().getTime();
                    var endtime = new Date(Date.parse(value)).getTime();
                    var nTime = begintime - endtime;
                    var day = Math.floor(nTime / 86400000);
                    max.date = max.date + day;

                    endIns.config.min = min;
                    endIns.config.max = max;
                    endIns.config.value = value;
                    $(endIns.config.elem).val(value);
                }
            });
            var endIns = laydate.render({
                elem: '#datetime3',
                min: 'value',
                done: function (value, date, endDate) {}
            });
        });






        //总营业额
        var ydata=[];
        var xdate=[];
        $.ajax({
            method: "POST",
            url: "totalIncome",
            data: { '_token':'{{csrf_token()}}'},
            // async: false,
            dataType: "",
            success:function (eval) {
                if ( eval.code == '200'&& eval.data.incomes.length>0 ) {

                    $.each(eval.data.incomes, function (index, item) {
                        ydata.push(item.dailyIncome);
                        xdate.push(item.date.substring(6)) ;

                    })
                    console.log( eval.data.monthlyIncome);
                    showLineChart(xdate,ydata,eval.data.monthlyIncome,Xunit='日',date='',id='main',title='总营业额',titleUnit='元');



                }else if(eval.code == '200'&& eval.data.incomes.length==0){
                    $('#main').html('总营业额暂无数据');
                }else if ( eval.code == '666' ) {
                    loginFaild();
                }
            }
        });


       // 分类统计收入
      var legendData=[];
      var value=[];
      var data=[];
        $.ajax({
            method: "POST",
            url: "classification",
            data: {  '_token':'{{csrf_token()}}'},
            // async: false,
            dataType: "",
            success:function (eval) {
                if ( eval.code == '200' && eval.data.length>0) {
                    $.each(eval.data, function (index, item) {
                        if(item.commissionType==0){
                            item.commissionType='基础保全';
                        }else if(item.commissionType==1){
                            item.commissionType='合同 ';
                        }else if(item.commissionType==2){
                            item.commissionType='凭证 ';
                        }else if(item.commissionType==3){
                            item.commissionType='溯源 ';
                        }
                        legendData.push(item.commissionType);
                        value.push(item.totalIncome) ;
                        data.push({value:item.totalIncome, name:item.commissionType});


                    })
                    console.log( legendData);
                    console.log( value);
                    console.log( data);

                    showPieChart(legendData,seriesName='收入来源',data,id='annularChart',title='');



                }else if(eval.code == '200' && eval.data.length==0){
                    $('#annularChart').html('分类统计收入暂无数据');
                }else if ( eval.code == '666' ) {

                }
            }
        });


        //   推荐总人数
        var ydatareference =[];
        var xdatereference =[];

        $.ajax({
            method: "POST",
            url: "reference",
            data: { '_token':'{{csrf_token()}}'},
            // async: false,
            dataType: "",
            success:function (eval) {
                if ( eval.code == '200'&& eval.data.reference.length>0 ) {
                    var totalRe=0;//推荐总人数
                    $.each(eval.data.reference, function (index, item) {

                        ydatareference .push(item.count);
                        xdatereference .push(item.registTime.substring(6)) ;

                        totalRe += parseInt(item.count)


                    })



                    showLineChart(xdatereference ,ydatareference ,totalRe,Xunit='日',date='',id='main3',title='推荐总人数',titleUnit='人');



                }else if(eval.code == '200'&& eval.data.reference.length==0 ){
                    $('#main3').html('推荐总人数暂无数据');
                    // $('#main3').css('height','50px');

                } else if ( eval.code == '666' ) {

                }
            }
        });



        // 分类统计人数
        var legendDatape=[];
        var valuepe=[];
        var datape=[];
        $.ajax({
            method: "POST",
            url: "classificationPe",
            data: {  '_token':'{{csrf_token()}}'},
            // async: false,
            dataType: "",
            success:function (eval) {
                if ( eval.code == '200' && eval.data.length>0) {
                    $.each(eval.data, function (index, item) {
                        if(item.rank==0){
                            item.rank='普通用户';
                        }else if(item.rank==1){
                            item.rank='经销商 ';
                        }else if(item.rank==2){
                            item.rank='合伙人 ';
                        }else if(item.rank==3){
                            item.rank='服务中心 ';
                        }
                        legendDatape.push(item.rank);
                        valuepe.push(item.count) ;
                        datape.push({value:item.count, name:item.rank});


                    })
                    console.log( legendDatape);
                    console.log( valuepe);
                    console.log( datape);

                    showPieChart(legendDatape,seriesName='代理商类型',datape,id='annularChart4',title='');



                }else if(eval.code == '200' && eval.data.length==0){
                    $('#annularChart4').html('分类统计人数暂无数据');
                }else if ( eval.code == '666' ) {

                }
            }
        });








    })



    //折线图
    //ydata:Y轴坐标；   xdata:X轴坐标；   Xunit：X轴坐标单位;    date:传入的时间   计算ydata总和：totalYdata   id:div的id，即在哪里显示
//title：标题       titleUnit：标题里的单位
    function showLineChart(xdata,ydata,totalYdata,Xunit,date,id,title,titleUnit) {

        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById(id));

        //计算ydata总和


        //根据date 获取x轴数据
        if(date){

        }


        // 指定图表的配置项和数据
        var option = {


            title :{
                text :title+'：'+totalYdata+titleUnit,
                // backgroundColor:'white',
                // subtext :' ',
                // x:'250px',
                // y:' 0px',
                // link :'http://www.baidu.com'
            },


            tooltip : {

                trigger : 'axis',
                show:true,
                showDelay: 0,
                hideDelay: 0,
                transitionDuration:0,
                backgroundColor : 'rgba(255,0,255,0.7)',
                borderColor : '#f50',
                borderRadius : 8,
                borderWidth: 2,
                padding: 10,    // [5, 10, 15, 20]
                formatter: function (params,ticket,callback) {
                    // console.log(params);
                    // return params[0].name +":" + params[0].data;
                    // return params[0].name +"日:" + params[0].data+"元";
                    return  params[0].data;
                }
            },
            xAxis: {
                type: 'category',
                data: xdata,
                name:Xunit
            },
            yAxis: {
                type: 'value',
                // name:'营业额/单位'
            },
            series: [{
                data: ydata,
                type: 'line'
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    }


    //饼状图
    function showPieChart(legendData,seriesName,data,id,title) {


        var annularChart = echarts.init(document.getElementById(id));

        var  option = {
            title :{
                text :title,
                backgroundColor:'#f0f2f5',
                subtext :' ',
                x:'240px',
                y:' 0px',
                // link :' '
            },
            tooltip: {
                trigger: 'item',
                formatter: "{a} <br/>{b}: {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                x: 'left',
                data:legendData,
            },
            series: [
                {
                    name:seriesName,
                    type:'pie',
                    radius: ['50%', '70%'],
                    avoidLabelOverlap: false,
                    label: {
                        normal: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            show: true,
                            textStyle: {
                                fontSize: '30',
                                fontWeight: 'bold'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    data:data,
                }
            ]
        };

        // 使用刚指定的配置项和数据显示图表。
        annularChart.setOption(option);


    }









    function loginFaild() {

        alert('登录失效')
        var t = setInterval(function () {
            window.location.href="login";
            clearInterval(t);
        }, 2000);
    }
    
    
    
    
    
    //总营业额时间查询
    function searchIncome() {

        var incomeyear=$('#incomeyear').val()
        var incomemonth=$('#incomemonth').val()


        var date;
        if(incomemonth!=''){
            if( incomemonth>12 || incomemonth<1){
                layui.use(['layer', 'form'], function(){
                    var layer = layui.layer;
                    layer.msg('请输入正确的月份');
                });
                return false;
            }
        }


        if(incomeyear.length!=4){
            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;
                layer.msg('请输入4位数年份');
            });
            return false;
        }


        if(incomeyear&&incomemonth){
            date=incomeyear+'-'+incomemonth;
        }else if(incomeyear){
            date=incomeyear;
        }else if(!incomeyear){
            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;
                layer.msg('请输入年份');
            });
            return false;
        }else if(!incomeyear||!incomemonth){
            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;
                layer.msg('请选择时间');
            });
            return false;
        }


        // alert(date);return false;


        var ydata=[];
        var xdate=[];
        var Xunit='';
        $.ajax({
            method: "POST",
            url: "totalIncome",
            data: {'date':date, '_token':'{{csrf_token()}}'},
            // async: false,
            dataType: "",
            success:function (eval) {
                // alert(eval.data.incomes.length)
                if ( eval.code == '200' && eval.data.incomes.length>0) {
                    $.each(eval.data.incomes, function (index, item) {

                        if(incomeyear&&incomemonth){//输入了年 月
                            xdate.push(item.date.substring(6)) ;
                            ydata.push(item.dailyIncome);
                            Xunit='日';
                        }else if(incomeyear){//输入了年
                            xdate.push(item.date.substring(4)) ;
                            ydata.push(item.dailyIncome);
                            Xunit='月';
                        }

                    })
                    console.log('eval.data.monthlyIncome='+ eval.data.monthlyIncome);
                    showLineChart(xdate,ydata,eval.data.monthlyIncome,Xunit=Xunit,date='',id='main',title='总营业额',titleUnit='元');



                }else if(eval.code == '200' && eval.data.incomes.length==0){
                    $.each(eval.data.incomes, function (index, item) {

                        if(incomeyear&&incomemonth){//输入了年 月
                            xdate.push(item.date.substring(6)) ;
                            ydata.push(item.dailyIncome);
                            Xunit='日';
                        }else if(incomeyear){//输入了年
                            xdate.push(item.date.substring(4)) ;
                            ydata.push(item.dailyIncome);
                            Xunit='月';
                        }

                    })
                    console.log('eval.data.monthlyIncome='+ eval.data.monthlyIncome);
                    showLineChart(xdate,ydata,eval.data.monthlyIncome,Xunit=Xunit,date='',id='main',title='总营业额',titleUnit='元');
                    layui.use(['layer', 'form'], function(){
                        var layer = layui.layer;

                        layer.msg('暂无数据');
                    });

                }else if ( eval.code == '666' ) {
                    loginFaild();
                }

            }
        });

    }
    
    
    
    

    //分类统计收入时间查询
  function searchclassification() {
        var startDate=$('#datetime').val()
        var endDate=$('#datetime1').val()
      // alert(startDate )
      // alert(endDate)

      if(!startDate||!endDate){

          layui.use(['layer', 'form'], function(){
              var layer = layui.layer;


              layer.msg('请选择起止时间');
          });
            return false;
      }else if(endDate  < startDate   ){
          layui.use(['layer', 'form'], function(){
              var layer = layui.layer;


              layer.msg('结束时间必须不小于开始时间');
          });
          return false;
      }


      var legendData=[];
      var value=[];
      var data=[];
      $.ajax({
          method: "POST",
          url: "classification",
          data: {'startDate':startDate,'endDate':endDate, '_token':'{{csrf_token()}}'},
          // async: false,
          dataType: "",
          success:function (eval) {
              if ( eval.code == '200' && eval.data.length>0) {
                  $.each(eval.data, function (index, item) {
                      if(item.commissionType==0){
                          item.commissionType='基础保全';
                      }else if(item.commissionType==1){
                          item.commissionType='合同 ';
                      }else if(item.commissionType==2){
                          item.commissionType='凭证 ';
                      }else if(item.commissionType==3){
                          item.commissionType='溯源 ';
                      }
                      legendData.push(item.commissionType);
                      value.push(item.totalIncome) ;
                      data.push({value:item.totalIncome, name:item.commissionType});


                  })
                  console.log( legendData);
                  console.log( value);
                  console.log( data);

                  showPieChart(legendData,seriesName='收入来源',data,id='annularChart',title='');



              }   else    if ( eval.code == '200' && eval.data.length==0) {
                  $.each(eval.data, function (index, item) {
                      if(item.commissionType==0){
                          item.commissionType='基础保全';
                      }else if(item.commissionType==1){
                          item.commissionType='合同 ';
                      }else if(item.commissionType==2){
                          item.commissionType='凭证 ';
                      }else if(item.commissionType==3){
                          item.commissionType='溯源 ';
                      }
                      legendData.push(item.commissionType);
                      value.push(item.totalIncome) ;
                      data.push({value:item.totalIncome, name:item.commissionType});


                  })
                  console.log( legendData);
                  console.log( value);
                  console.log( data);

                  showPieChart(legendData,seriesName='收入来源',data,id='annularChart',title='');
                  layui.use(['layer', 'form'], function(){
                      var layer = layui.layer;

                      layer.msg('暂无数据');
                  });


              }  else if ( eval.code == '666' ) {

              }
          }
      });

  }

    //推荐总人数  时间查询
    function searchReference() {
// alert(1)
        var referenceyear=$('#referenceyear').val()
        var referencemonth=$('#referencemonth').val()

        // alert(referenceyear)
        // alert(referencemonth)

        var date;

        if(referencemonth!=''){
            if( referencemonth>12 || referencemonth<1){
                layui.use(['layer', 'form'], function(){
                    var layer = layui.layer;
                    layer.msg('请输入正确的月份');
                });
                return false;
            }
        }



        if(referenceyear.length!=4){
            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;
                layer.msg('请输入4位数年份');
            });
            return false;
        }

        if(referenceyear&&referencemonth){
            date=referenceyear+'-'+referencemonth;
        }else if(referenceyear){
            date=referenceyear;
        }else if(!referenceyear){

            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;


                layer.msg('请输入年份');
            });

            return false;
        }else if(!referenceyear&&!referencemonth){

            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;


                layer.msg('请选择时间');
            });
            return false;
        }

        // alert(date);return false;


        var ydatareference=[];
        var xdatereference=[];
        var Xunit='';
        $.ajax({
            method: "POST",
            url: "reference",
            data: {'date':date,  '_token':'{{csrf_token()}}'},
            async: false,
            dataType: "",
            success:function (eval) {
                if ( eval.code == '200' &&  eval.data.reference.length>0) {
                    var totalRe=0;//推荐总人数
                    $.each(eval.data.reference, function (index, item) {

                        if(referenceyear&&referencemonth){//输入了年 月

                            ydatareference.push(item.count);
                            xdatereference.push(item.registTime.substring(6)) ;
                            Xunit='日';
                            totalRe += parseInt(item.count);


                        }else if(referenceyear&&!referencemonth){//只输入了年
                            xdatereference.push(item.registTime.substring(4)) ;
                            ydatareference.push(item.count);
                            Xunit='月';
                            totalRe += parseInt(item.count);
                        }



                    })

                    showLineChart(xdatereference,ydatareference,totalRe,Xunit=Xunit,date='',id='main3',title='推荐总人数',titleUnit='人');



                }
                else if(eval.code == '200' && eval.data.reference.length==0)  {
                    var totalRe=0;//推荐总人数
                    $.each(eval.data.reference, function (index, item) {

                        if(referenceyear&&referencemonth){//输入了年 月

                            ydatareference.push(item.count);
                            xdatereference.push(item.registTime.substring(6)) ;
                            Xunit='日';
                            totalRe += parseInt(item.count);


                        }else if(referenceyear&&!referencemonth){//只输入了年
                            xdatereference.push(item.registTime.substring(4)) ;
                            ydatareference.push(item.count);
                            Xunit='月';
                            totalRe += parseInt(item.count);
                        }



                    })

                    showLineChart(xdatereference,ydatareference,totalRe,Xunit=Xunit,date='',id='main3',title='推荐总人数',titleUnit='人');

                    var totalRe=0;//推荐总人数
                    $.each(eval.data.reference, function (index, item) {

                        if(referenceyear&&referencemonth){//输入了年 月

                            ydatareference.push(item.count);
                            xdatereference.push(item.registTime.substring(6)) ;
                            Xunit='日';
                            totalRe += parseInt(item.count);


                        }else if(referenceyear&&!referencemonth){//只输入了年
                            xdatereference.push(item.registTime.substring(4)) ;
                            ydatareference.push(item.count);
                            Xunit='月';
                            totalRe += parseInt(item.count);
                        }



                    })

                    showLineChart(xdatereference,ydatareference,totalRe,Xunit=Xunit,date='',id='main3',title='推荐总人数',titleUnit='人');
                    layui.use(['layer', 'form'], function(){
                        var layer = layui.layer;

                        layer.msg('暂无数据');
                    });

                }
                else if ( eval.code == '666' ) {
                    loginFaild();
                }
            }
        });

    }


    //分类统计人数  时间查询
     function searchclassificationPe() {
         var startDate=$('#datetime2').val()
         var endDate=$('#datetime3').val()
         // alert(startDate)
         // alert(endDate)

         if(!startDate||!endDate){
             layui.use(['layer', 'form'], function(){
                 var layer = layui.layer;


                 layer.msg('请选择起止时间');
             });
             return false;
         }else if(endDate  < startDate   ){
             layui.use(['layer', 'form'], function(){
                 var layer = layui.layer;


                 layer.msg('结束时间必须不小于开始时间');
             });
             return false;
         }



        var legendDatape=[];
        var valuepe=[];
        var datape=[];
        $.ajax({
            method: "POST",
            url: "classificationPe",
            data: { 'startDate':startDate,'endDate':endDate, '_token':'{{csrf_token()}}'},
            // async: false,
            dataType: "",
            success:function (eval) {
                if ( eval.code == '200' && eval.data.length>0) {
                    $.each(eval.data, function (index, item) {
                        if(item.rank==0){
                            item.rank='普通用户';
                        }else if(item.rank==1){
                            item.rank='经销商 ';
                        }else if(item.rank==2){
                            item.rank='合伙人 ';
                        }else if(item.rank==3){
                            item.rank='服务中心 ';
                        }
                        legendDatape.push(item.rank);
                        valuepe.push(item.count) ;
                        datape.push({value:item.count, name:item.rank});


                    })
                    console.log( legendDatape);
                    console.log( valuepe);
                    console.log( datape);

                    showPieChart(legendDatape,seriesName='代理商类型',datape,id='annularChart4',title='');



                }else if ( eval.code == '200' && eval.data.length==0) {
                    $.each(eval.data, function (index, item) {
                        if(item.rank==0){
                            item.rank='普通用户';
                        }else if(item.rank==1){
                            item.rank='经销商 ';
                        }else if(item.rank==2){
                            item.rank='合伙人 ';
                        }else if(item.rank==3){
                            item.rank='服务中心 ';
                        }
                        legendDatape.push(item.rank);
                        valuepe.push(item.count) ;
                        datape.push({value:item.count, name:item.rank});


                    })
                    console.log( legendDatape);
                    console.log( valuepe);
                    console.log( datape);

                    showPieChart(legendDatape,seriesName='代理商类型',datape,id='annularChart4',title='');

                    layui.use(['layer', 'form'], function(){
                        var layer = layui.layer;

                        layer.msg('暂无数据');
                    });

                }else if ( eval.code == '666' ) {

                }
            }
        });



    }



</script>